{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "9f6cad41",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "            x1        x2        x3     x4        x5     x6        x7      x8  \\\n",
      "year                                                                           \n",
      "2004  12113416  18895479  10092421  559.6   2075416  31.99   3733922   80922   \n",
      "2005  14859261  21627825  11751668  554.5   3184744  29.87   4785787  167217   \n",
      "2006  17880638  25453413  13489283  566.1   3981959  30.69   5459314  154958   \n",
      "2007  20452183  29787941  15191582  575.2   4048305  31.63   6331382  186678   \n",
      "2008  24415160  35118425  16963824  582.1   5388451  28.95   6870406  219390   \n",
      "2009  28257805  41646681  18633437  599.0   7531147  24.88   7507109  376839   \n",
      "2010  32278717  48903250  21055373  633.1   6930269  30.85   8754491  458096   \n",
      "2011  34051588  55607710  26598516  612.8   7791165  23.16  10134050  485760   \n",
      "2012  40022658  65574525  32635731  632.4  10312744  20.42  12805288  653736   \n",
      "2013  45769763  76419207  34122005  664.7   9585263  22.55  15613171  668043   \n",
      "2014  47206504  86167948  37583868  677.3   8256048  20.90  17417072  703733   \n",
      "2015  52273431  99643373  44545508  680.7  11053751  19.70  21828895  877889   \n",
      "\n",
      "            x9       x10        y  \n",
      "year                               \n",
      "2004   1053156   2690984   236416  \n",
      "2005   1154425   3005475   268360  \n",
      "2006   1434440   3384477   326556  \n",
      "2007   3621757   4088545   373397  \n",
      "2008   4196301   4767231   455820  \n",
      "2009   7068265   8389925   596693  \n",
      "2010  17829885   8431405   756412  \n",
      "2011  17019222  11076649   732282  \n",
      "2012  26192835  13991612   935248  \n",
      "2013  21639131  15351387  1061594  \n",
      "2014  21396742  15796804  1075045  \n",
      "2015  22659148  20881374  1155923  \n",
      "x1 0.9949025526727991\n",
      "x2 0.9809200625307004\n",
      "x3 0.9737967837440261\n",
      "x4 0.9875076813934874\n",
      "x5 0.9485720651319114\n",
      "x6 -0.883346411256355\n",
      "x7 0.9522558330462747\n",
      "x8 0.9885982546945923\n",
      "x9 0.9538475702930086\n",
      "x10 0.9767191718922321\n"
     ]
    }
   ],
   "source": [
    "# 1\n",
    "import pandas as pd\n",
    "\n",
    "# 2\n",
    "data = pd.read_csv('income_tax.csv')\n",
    "data.set_index('year', inplace=True)\n",
    "\n",
    "print(data)\n",
    "\n",
    "# 3\n",
    "new_data = data.iloc[:,0:10]\n",
    "# print(new_data)\n",
    "y = data.iloc[:, -1]\n",
    "\n",
    "\n",
    "def correlation(x, y):\n",
    "    meanX = x.mean()\n",
    "    deviationX = x.std(ddof=0)\n",
    "    stardardizedX = (x - meanX) / deviationX\n",
    "    \n",
    "    meanY = y.mean()\n",
    "    deviationY = y.std(ddof=0)\n",
    "    stardardizedY = (y - meanY) / deviationY\n",
    "    return (stardardizedX*stardardizedY).mean()\n",
    "\n",
    "# 4\n",
    "for column in new_data.columns:\n",
    "    print(column + ' ' + str(correlation(new_data[column], y)))\n",
    "\n",
    "\n",
    "# print(correlation(new_data['x1'], y))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "00f37b98",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
